package com.example.tidycalendartest;

import java.util.Date;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class EventList {
	protected SQLiteDatabase db;
	
	public EventList(SQLiteDatabase db)
	{
		this.db = db;
	}
	
	public boolean add(Event e)
	{
		//Put the members of e into a ContentValues object that will then store the data in the db
		
		ContentValues values = new ContentValues();
		
		values.put("event_id", e.getEventId());
		values.put("name", e.getName());
		values.put("description", e.getDescription());
		values.put("category_id", e.getCategoryId());
		values.put("start_date", e.getStartDate().toString());
		values.put("end_date", e.getEndDate().toString());
		
		long row_id = db.insert("events", null, values);
		
		return row_id != -1;	
	}
	
	public boolean remove(Event e)
	{
		return false;
	}
	
	public Integer getCount()
	{
		//Return the number of all rows in the events table.
		Cursor c = db.rawQuery("select count(*) from events", null);
		c.moveToFirst();
		return c.getInt(0);
	}

}
